<?php
$vayname = "";
$idloan = "";
if(isset($_GET['as'])) {
	$check = true;
	$idloan = $_GET['as'];
	if($idloan == "vay_ca_nhan") {
		$vayname = "Vay Cá Nhân";
	} else if($idloan == "vay_tra_gop") {
		$vayname = "Vay Trả Góp";
	} else if($idloan == "vay_the_chap") {
		$vayname = "Vay Thế Chấp";
	} else {
		$check = false;
	}
	
	if($check) {
		?>
 

<h3>Thêm Câu Hỏi Thường Gặp <?php echo($vayname) ?></h3>
<div style="color: red;">
<?php
	if(isset($_GET['mess'])) {
		echo($_GET['mess']);
	}
?>
</div>
<div style="width: 850px;">
	<form action="../src/control/adminquestion.php" method="post" onSubmit="return checkvaluequestion();">
        <table>
            <tr>
                <th valign="top" width="100px;">Câu Hỏi</th>
                <td>
                    <input type="hidden" value="<?php echo($idloan) ?>" name="vayid" id="vayid" />
                    <input id="textfieldquestion" name="textfieldquestion" type="text" style="width: 750px; height:30px; padding-left:5px; padding-right:5px;" /><br><font color="red"><span id="err_cauhoi"></span></font>
                </td>
            </tr>
            <tr>
            	<th valign="top">Trả Lời</th>
                <td>
                	<textarea id="textfieldanswerquestion" name="textfieldanswerquestion" rows="20" cols="200" style="width: 750px; max-width:750px; min-width:750px;" class="tinymce"></textarea><br><font color="red"><span id="err_cautraloi"></span></font>
                </td>
            </tr>
            <tr>
            	<th colspan="2"><input type="hidden" name="acc" value="them" /><input type="submit" value="Lưu" style="border-radius: 5px; padding:5px; width:50px; background:#03F; color:#FFF; font-weight:bold;" /></th>
            </tr>
        </table>
    </form>
</div>
<script>
function checkvaluequestion() {
	var cauhoi = $.trim($('#textfieldquestion').val());
	var answer = $.trim($('#textfieldanswerquestion').val());
	
	if(cauhoi.length == 0) {
		$('#err_cauhoi').html("Vui lòng nhập thông tin câu hỏi!");
		$('#textfieldquestion').focus();
		return false;
	} else {
		$('#err_cauhoi').html("");
	}
	
	if(answer.length == 0) {
		$('#err_cautraloi').html("Vui lòng nhập thông tin câu trả lời!");
		$('#textfieldanswerquestion').focus();
		return false;
	} else {
		$('#err_cautraloi').html("");
	}
}
</script>
        <?php
	}
}
?>
